//
//  HelpHandel.m
//  NEWS_W_Y_S
//
//  Created by lanou3g on 15/10/14.
//  Copyright © 2015年 lanou3g.jake. All rights reserved.
//

#import "HelpHandel.h"
#import "UrlConnection.h"
#import "VideoModel.h"
static HelpHandel *help = nil;

@implementation HelpHandel

+(HelpHandel *)shareVideoHandel{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        help = [[HelpHandel alloc] init];
    });
    return help;
}

-(void)requestWithUrl:(NSString *)url block:(void (^)(NSMutableArray *))block{
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
       
        [UrlConnection startConnection:url parmaters:nil connetionBlock:^(NSDictionary *responseObject) {
            
            NSArray *array = responseObject[@"V9LG4B3A0"];
            _dataArray = [NSMutableArray array];
            
            for (NSDictionary *dic in array) {
                VideoModel *model = [[VideoModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];
                [self.dataArray addObject:model];
            }
               dispatch_async(dispatch_get_main_queue(), ^{
                  block(_dataArray);
        });
       
        }];
        
    });
    
}


@end
